unit UModule_Entry_Siswa_SPP;

interface

uses
  soap_sis_entry_siswa_spp,
  Dialogs,
  Controls,
  SysUtils,
  Classes,
  InvokeRegistry,
  Rio,
  XSBuiltIns,
  SOAPHTTPClient,
  ActnList;

type
  TModule_Entry_Siswa_SPP = class(TDataModule)
    HTTPRIO1: THTTPRIO;
    ActionList1: TActionList;
    PFile_Simpan: TAction;
    PMenu_Entry_SPP: TAction;
    PCommon_Daftar_Subject: TAction;
    procedure PFile_SimpanExecute(Sender: TObject);
    procedure PMenu_Entry_SPPExecute(Sender: TObject);
    procedure HTTPRIO1AfterExecute(const MethodName: string; SOAPResponse: TStream);
    procedure PCommon_Daftar_SubjectExecute(Sender: TObject);
  private
    FDataSiswa: TInfoDaftarSiswa;
    procedure Assign_LoginInfo;
  public
    procedure Assign_Action;
  end;

var
  Module_Entry_Siswa_SPP: TModule_Entry_Siswa_SPP;

implementation

uses
  UMainApplication,
  UUser;
{$R *.dfm}

procedure TModule_Entry_Siswa_SPP.Assign_Action;
begin
try
  with Form_Main do
    begin
    TMB0105010601040201.Action := PFile_Simpan;
    TMB01050106010401.Action   := PCommon_Daftar_Subject;
    with CB010501 do
      begin
      with Categories[6] do
        begin
        Items[0].Action := PMenu_Entry_SPP;
        end;
      end;
    end;
except
  on E: Exception do
    begin
    ShowMessage(E.Message);
    end;
end;
end;

procedure TModule_Entry_Siswa_SPP.Assign_LoginInfo;
begin
try
  with Form_Main do
    begin
    GServer_Host     := IN010301.Text;
    GServer_Database := IN010302.Text;
    GServer_UserName := IN010303.Text;
    GServer_Password := IN010304.Text;
    GUserName        := LE01010101.Text;
    GUserPassword    := LE01010102.Text;
    end;
except
  on E: Exception do
    begin
    ShowMessage(E.Message);
    end;
end;
end;

procedure TModule_Entry_Siswa_SPP.HTTPRIO1AfterExecute(const MethodName: string; SOAPResponse: TStream);
var
  LocalStrings: TStringList;
begin
try
  LocalStrings          := TStringList.Create;
  SOAPResponse.Position := 0;
  LocalStrings.LoadFromStream(SOAPResponse);
  // ShowMessage(LocalStrings.Text);
  FreeAndNil(LocalStrings);
except
  on E: Exception do
    begin
    ShowMessage(E.Message);
    end;
end;
end;

procedure TModule_Entry_Siswa_SPP.PCommon_Daftar_SubjectExecute(Sender: TObject);
var
  InfoServer: TInfoServer;
  LocalIndex: word;
  LocalCount: integer;
begin
try
  with HTTPRIO1 as SERVICE_ENTRY_SISWA_SPPPortType do
    begin
    Assign_LoginInfo;
    InfoServer                 := TInfoServer.Create;
    InfoServer.Server_Host     := GServer_Host;
    InfoServer.Server_Database := GServer_Database;
    InfoServer.Server_Username := GServer_UserName;
    InfoServer.Server_Password := GServer_Password;
    DATA_SISWA(InfoServer, FDataSiswa);
    with Form_Main do
      begin
      LocalCount := high(FDataSiswa);
      if LocalCount > 0 then
        begin
        with IN01050106010401, Items do
          begin
          BeginUpdate;
          Clear;
          for LocalIndex := 0 to high(FDataSiswa) do
            begin
            with FDataSiswa[LocalIndex] do
              begin
              Add(SISWA_KODE + ' - ' + SISWA_NAMA_AWAL);
              end;
            end;
          EndUpdate;
          ItemIndex := 0;
          end;
        end;
      end;
    end;
except
  on E: Exception do
    begin
    ShowMessage(E.Message);
    end;
end;
end;

procedure TModule_Entry_Siswa_SPP.PFile_SimpanExecute(Sender: TObject);
var
  InfoServer:      TInfoServer;
  DataSPPInputRow: TDataSPPInputRow;
  DataSPPInput:    TDataSPPInput;
  InfoDate:        TXSDateTime;
begin
try
  Assign_LoginInfo;
  InfoServer                 := TInfoServer.Create;
  DataSPPInputRow            := TDataSPPInputRow.Create;
  InfoDate                   := TXSDateTime.Create;
  InfoServer.Server_Host     := GServer_Host;
  InfoServer.Server_Database := GServer_Database;
  InfoServer.Server_Username := GServer_UserName;
  InfoServer.Server_Password := GServer_Password;
  with Form_Main, HTTPRIO1 as SERVICE_ENTRY_SISWA_SPPPortType do
    begin
    DataSPPInputRow.SISWA_ID       := FDataSiswa[IN01050106010401.ItemIndex].ID;
    InfoDate.AsDateTime            := IN01050106010402.DateTime;
    DataSPPInputRow.SPP_TGL        := InfoDate;
    DataSPPInputRow.SPP_NILAI      := StrToInt(IN01050106010403.Text);
    DataSPPInputRow.SPP_KETERANGAN := IN01050106010404.Text;
    SetLength(DataSPPInput, 1);
    DataSPPInput[0] := DataSPPInputRow;
    SISWA_SIMPAN_SPP_DATASET(InfoServer, DataSPPInput);
    end;
except
  on E: Exception do
    begin
    ShowMessage(E.Message);
    end;
end;
end;

procedure TModule_Entry_Siswa_SPP.PMenu_Entry_SPPExecute(Sender: TObject);
begin
try
  with Form_Main, TAB010501060104 do
    begin
    Show;
    end;
except
  on E: Exception do
    begin
    ShowMessage(E.Message);
    end;
end;
end;

end.
